/*****************************************************************************/
/**
 *  @file   Event.h
 *  @author Naohisa Sakamoto
 */
/*----------------------------------------------------------------------------
 *
 *  Copyright (c) Visualization Laboratory, Kyoto University.
 *  All rights reserved.
 *  See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details.
 *
 *  $Id$
 */
/*****************************************************************************/
#ifndef EVENT_H_INCLUDE
#define EVENT_H_INCLUDE

#include <kvs/TimerEventListener>
#include <kvs/KeyPressEventListener>

#include "Parameter.h"
#include "Command.h"


namespace Event
{

class KeyPressEvent : public kvs::KeyPressEventListener
{
    Parameter& m_parameter;

public:

    KeyPressEvent( Parameter& parameter ): m_parameter( parameter ) {};

    void update( kvs::KeyEvent* event )
    {
        switch ( event->key() )
        {
        case kvs::Key::s: { Command::Snapshot( screen() ); break; }
        case kvs::Key::w:
        {
            static bool f = true;
            if ( f ) { Command::HideWidgets( m_parameter ); f = false; }
            else { Command::ShowWidgets( m_parameter ); f = true; }
            break;
        }
        default: break;
        }
    }
};

class TimerEvent : public kvs::TimerEventListener
{
    void update( kvs::TimeEvent* e ) { screen()->redraw(); }
};

} // end of namespace Event

#endif // EVENT_H_INCLUDE
